<?php
namespace Core\CoreContracts;

require_once(CONTRACTS_DIR . 'statesuser.enum.php');
require_once(CONTRACTS_DIR . 'profilesuser.enum.php');
/*
* User definition
*/
class User 
{
	/**
    * @property integer The user unique identifier
    */
	public $Id;
	
	/**
    * @property string The user first name
    */
	public $Firstname;
	
	/**
    * @property string The last name
    */
	public $Lastname;
	
	/**
    * @property string The mail address 
    */
	public $Email;

	/**
    * @property string The phone number
    */
	public $PhoneNumber;

	/**
    * @property integer The user state ('Unknown','Online','Offline', 'Banned')
    */
	public $State;
	
	/**
    * @property integer The user profile ('User','Member','Administrator')
    */
	public $Profile;
	
	/**
    * @property string The user login
    */
	public $Login;
	
	/**
    * @property string The user password in sha1
    */
	public $Password;
	
	/**
    * @property datetime The user modification date
    */
	public $ModificationDate;
	
	/**
    * @property datetime The user creation date
    */
	public $CreationDate;
	
	/**
	* The default constructor
	*/
	public function __construct()  {  }
	
	/*
	* Build a new user object
	*
	* @param string $firstname The fisrt name
	* @param string $lastname The last name
	* @param string $email The email
	* @param string $phonenumber The phone number
	* @param string $login The login
	* @param string $password The password
	*/
	public static function Create($firstname, $lastname, $email, $phonenumber, $login, $password)
	{
		$user = new User();
		$user->Firstname = $firstname;
		$user->Lastname = $lastname;
		$user->Email = $email;
		$user->PhoneNumber = $phonenumber;
		$user->State = StateUser::Online;
		$user->Profile = ProfileUser::User;
		$user->Login = $login;		
		$user->Password = sha1($password);				
		$user->ModificationDate = date("Y-m-d H:i:s");
		$user->CreationDate = date("Y-m-d H:i:s");
		return $user ;
	}
	
	public function  __toString()
	{
		return sprintf("%s %s", $this->Firstname, $this->Lastname);
	}
}
?> 